﻿using System;
using System.Collections.Generic;
using System.Text;
using WinnerCMS.Common;
using WinnerCMS.BLL.PageFactory;
namespace WinnerCMS.PlugIn.Task
{
    public class AutoMakeHTML : WinnerCMS.PlugIn.Scheduler.IScheduler
    {

        /// <summary>
        /// 执行
        /// </summary>
        /// <param name="parameterized">参数</param>
        /// <remarks>参数格式：ModelId,方法,方法的参数</remarks>
        /// <example>2,ContentPage,20</example>
        public void Execute(object parameterized)
        {
            string[] CommandLine = parameterized.ToString().Split(',');

            Path = HttpServer.MapPath("/");
            ModelId = byte.Parse(CommandLine[0]);
            Method = CommandLine[1];
            parameter = CommandLine[2];

            SaveHTML sh = new SaveHTML(ModelId);
            switch (Method)
            {
                case "ContentPage":
                    if (MyValidate.IsNumeric(parameter))
                        sh.ContentPage(int.Parse(parameter));
                    else
                        sh.ContentPage(parameter);
                    break;
                case "CategoryPage":
                    sh.CategoryPage(parameter);
                    break;
                case "SpecialPage":
                    sh.SpecialPage(parameter);
                    break;
                
                case "IndexPage":
                    sh.IndexPage();
                    break;
                case "ALL":
                    sh.ALL(ModelId);
                    break;
            }
        }

        private byte _ModelId;
        private byte ModelId
        {
            get { return _ModelId; }
            set { _ModelId = value; }
        }

        private string _Path;
        private string Path
        {
            get { return _Path; }
            set { _Path = value; }
        }
        private string _method;
        private string Method
        {
            get { return _method; }
            set { _method = value; }
        }
        private string _parameter;
        private string parameter
        {
            get { return _parameter; }
            set { _parameter = value; }
        }

    }
}